dynamic class com.c3d.mediaRotator.ui.TabbedOverlay extends MovieClip
{
    var _isReady: Boolean = false;
    var _tabMarginX: Number = 2;
    var _adOutlineWidth: Number = 10;
    var _adOutlineMC;
    var _controller;
    var _outlineStrokeBlocker;
    var _overlayCorner;
    var _tabClips;
    var _tabList;
    var _tabMCGroup;
    var createEmptyMovieClip;
    var getNextHighestDepth;

    function TabbedOverlay()
    {
        super();
        this._tabList = new Array();
        this._tabClips = new Array();
        this._overlayCorner = new flash.geom.Point(65, 355);
        this._tabMCGroup = this.createEmptyMovieClip("tabMcGroup", this.getNextHighestDepth());
        this.attachEventListeners();
        com.c3d.common.events.CentralDispatch.dispatchEvent({type: "tabbedOverlayAttached", target: this});
    }

    function initialize($controller)
    {
        this._controller = $controller;
        this._adOutlineMC = this.createAdOutline();
        this._tabList = this._controller.panelTabInfo;
        this.populateTabs();
        this._outlineStrokeBlocker = this.createOutlineStrokeBlocker();
        this.positionOutlineStrokeBlocker(0);
    }

    function createOutlineStrokeBlocker()
    {
        var __reg3 = this._controller.__get__bannerGlobalConfigParams();
        var __reg2 = this.createEmptyMovieClip("strokeBlocker_mc", this.getNextHighestDepth());
        __reg2.beginFill(__reg3.stageMarginFillColor, 100);
        __reg2.moveTo(0, 0);
        __reg2.lineTo(10, 0);
        __reg2.lineTo(10, 1);
        __reg2.lineTo(0, 1);
        __reg2.lineTo(0, 0);
        __reg2.endFill();
        return __reg2;
    }

    function populateTabs()
    {
        var __reg2 = 0;
        while (__reg2 < this._tabList.length) 
        {
            this._tabClips.push(this._tabMCGroup.attachMovie("tabbedOverlayTab_mc", "tab_" + __reg2, this._tabMCGroup.getNextHighestDepth()));
            ++__reg2;
        }
        this.initializeTabs(this._tabClips, this._tabList);
    }

    function initializeTabs($tabClips, $tabData)
    {
        var __reg7 = this._controller.__get__bannerGlobalConfigParams();
        var __reg8 = 60;
        var __reg2 = 0;
        while (__reg2 < $tabClips.length) 
        {
            var __reg4 = 0;
            if (__reg2 > 0) 
            {
                __reg4 = $tabClips[__reg2 - 1]._x + $tabClips[__reg2 - 1]._width;
            }
            $tabClips[__reg2]._x = __reg4 + this._tabMarginX;
            var __reg5 = this.getCurrentTabConfig(__reg2);
            $tabClips[__reg2].props = __reg5;
            $tabClips[__reg2].initialize($tabData[__reg2], __reg2);
            ++__reg2;
        }
        this._tabMCGroup._y = Stage.height - __reg8 / 2 - __reg7.stageMarginSize.y;
        this._tabMCGroup._x = this._overlayCorner.x;
        $tabClips[0].requestShowHighlight();
    }

    function getCurrentTabConfig($tabID)
    {
        var __reg2 = new Object({height: "60", width: "120", color: "0xffcc00", cornerradius: "10,10,0,0", dimcolor: "0xffffff", dimalpha: ".5", labelsize: "12", labelcolor: "0xff0000", labeldimalpha: ".5"});
        var __reg4 = this._controller.__get__bannerGlobalConfigParams().tabConfig;
        var __reg6 = this._controller.__get__currentPanelModels();
        __reg6.reverse();
        var __reg3 = __reg6[$tabID].tabConfig;
        for (var __reg5 in __reg2) 
        {
            if (__reg4[__reg5]) 
            {
                __reg2[__reg5] = __reg4[__reg5];
            }
            if (__reg3[__reg5]) 
            {
                __reg2[__reg5] = __reg3[__reg5];
            }
        }
        return __reg2;
    }

    function onAllTabsInitialized($event)
    {
    }

    function onTabPress($event)
    {
    }

    function onPanelTransition($event)
    {
        this.positionOutlineStrokeBlocker($event.newPanelIndex);
        var __reg2 = 0;
        for (;;) 
        {
            if (__reg2 >= this._tabClips.length) 
            {
                return;
            }
            if (__reg2 == $event.newPanelIndex) 
            {
                this._tabClips[__reg2].requestShowHighlight();
            }
            else 
            {
                this._tabClips[__reg2].requestHideHighlight();
            }
            ++__reg2;
        }
    }

    function onRequestedPanelTransition($event)
    {
        this.positionOutlineStrokeBlocker($event.newPanelIndex);
        var __reg2 = 0;
        for (;;) 
        {
            if (__reg2 >= this._tabClips.length) 
            {
                return;
            }
            if (__reg2 == $event.newPanelIndex) 
            {
                this._tabClips[__reg2].requestShowHighlight();
            }
            else 
            {
                this._tabClips[__reg2].requestHideHighlight();
            }
            ++__reg2;
        }
    }

    function positionOutlineStrokeBlocker($targetTabIndex)
    {
        var __reg2 = this._controller.__get__bannerGlobalConfigParams();
        this._outlineStrokeBlocker._width = this._tabClips[$targetTabIndex]._width;
        this._outlineStrokeBlocker._height = 1;
        this._outlineStrokeBlocker._x = this._tabClips[$targetTabIndex]._x + this._tabMCGroup._x;
        this._outlineStrokeBlocker._y = Stage.height - __reg2.stageMarginSize.y - 1;
    }

    function createAdOutline()
    {
        var __reg2 = this._controller.__get__bannerGlobalConfigParams();
        var __reg5 = __reg2.stageCornerRadius;
        var __reg3 = this.createEmptyMovieClip("adOutline_mc", this.getNextHighestDepth());
        var __reg4 = __reg2.stageMarginStrokeWidth / 2;
        if (__reg2.stageMarginSize.x > 0 || __reg2.stageMarginSize.y > 0) 
        {
            __reg3.beginFill(__reg2.stageMarginFillColor, 100);
            __reg3.lineStyle(__reg2.stageMarginStrokeWidth, __reg2.stageMarginStrokeColor);
            __reg3.moveTo(0, 0);
            __reg3.lineTo(__reg2.stageSize.x - 0.5 - __reg4, 0);
            __reg3.lineTo(__reg2.stageSize.x - 0.5 - __reg4, __reg2.stageSize.y - 0.5 - __reg5[2] - __reg4);
            __reg3.curveTo(__reg2.stageSize.x - 0.5 - __reg4, __reg2.stageSize.y - 0.5 - __reg4, __reg2.stageSize.x - 0.5 - __reg5[2] - __reg4, __reg2.stageSize.y - 0.5 - __reg4);
            __reg3.lineTo(__reg5[3], __reg2.stageSize.y - 0.5 - __reg4);
            __reg3.curveTo(0, __reg2.stageSize.y - 0.5 - __reg4, 0, __reg2.stageSize.y - 0.5 - __reg5[3] - __reg4);
            __reg3.lineTo(0, 0);
            __reg3.moveTo(__reg2.stageMarginSize.x, __reg2.stageMarginSize.y);
            __reg3.lineTo(__reg2.stageSize.x - __reg2.stageMarginSize.x - 0.5, __reg2.stageMarginSize.y);
            __reg3.lineTo(__reg2.stageSize.x - __reg2.stageMarginSize.x - 0.5, __reg2.stageSize.y - __reg2.stageMarginSize.y - 0.5);
            __reg3.lineTo(__reg2.stageMarginSize.x, __reg2.stageSize.y - __reg2.stageMarginSize.y - 0.5);
            __reg3.lineTo(__reg2.stageMarginSize.x, __reg2.stageMarginSize.y);
            __reg3.endFill();
        }
        return __reg3;
    }

    function requestNormalizeTabStyles($targetIndex)
    {
    }

    function attachEventListeners()
    {
        com.c3d.common.events.CentralDispatch.addEventListener(com.c3d.mediaRotator.events.PanelTransitionEvent.TRANSITION_CONTROLLER_TRANSITION_BEGIN, mx.utils.Delegate.create(this, this.onPanelTransition));
        com.c3d.common.events.CentralDispatch.addEventListener(com.c3d.mediaRotator.events.PanelTransitionEvent.TRANSITION_CONTROLLER_REQUESTED_TRANSITION_BEGIN, mx.utils.Delegate.create(this, this.onRequestedPanelTransition));
    }

    function get isReady()
    {
        return this._isReady;
    }

}
